<%@ page contentType="text/html; charset=utf-8" language="java"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.List"%>
<%@page import="com.travelsky.airchina.boarding.domain.Resource"%>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>管理中心 - 查看操作权限</title>
	<%@ include file="/common/meta.jsp" %>
	<link href="${ctx}/css/system/general.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/css/system/main.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/css/system/category.css" rel="stylesheet" type="text/css" />	
	<script type="text/javascript" src="${ctx}/js/checkFrameSet.js"></script>
      <style>
       <!--
        body{
      	   font-size:13px;
      	}
       -->
      </style> 
</head>
<body>
<h1>
<span class="action-span"><a href="${ctx}/system/resource/manage">操作权限列表</a></span>
<span class="action-span1"><a href="#">管理中心</a>  - 查看操作权限 </span>
<div style="clear:both"></div>
</h1>

<div class="main-div">
  <table width="100%" id="general-table">
      <tr>
        <td class="label">操作权限名称</td>
        <td>
          <input name="name" maxlength="20" size="27" value="${resource.name}" readonly="readonly"/> <font color="red">*</font></td>
      </tr>
      <tr>
        <td class="label">操作权限URI</td>
        <td><input name="url" maxlength="20" size="27" value="${resource.url}" readonly="readonly" /> <font color="red">*</font></td>
      </tr>
      <tr>
        <td class="label">上级操作权限</td>
        <td>
	       <div class="cascading-container">
		    <ol id="J_OlCascadingList">
		      <li id="l_1" class="root">
		        <ul id="u_1">
		           <c:choose>
		             <c:when test="${rootResourceId==null}">
		           <li id="-1" class="selected"><span>--根操作权限--</span></li>
		             </c:when>
		             <c:otherwise>
		           <li id="-1"><span>--根操作权限--</span></li>
		             </c:otherwise>
		           </c:choose>
			           <c:forEach items="${rootResources}" var="itemTemp">
			             <c:choose>
			                <c:when test="${itemTemp.isLeaf==0}">
					           <c:choose>
					             <c:when test="${rootResourceId==itemTemp.id}">
			           <li id="${itemTemp.id}" class="parent selected"><span>${itemTemp.name}</span></li>
					             </c:when>
					             <c:otherwise>
			           <li id="${itemTemp.id}" class="parent"><span>${itemTemp.name}</span></li>
					             </c:otherwise>
					           </c:choose>
			                </c:when>
			                <c:otherwise>
					           <c:choose>
					             <c:when test="${rootResourceId==itemTemp.id}">
			           <li id="${itemTemp.id}" class="selected"><span>${itemTemp.name}</span></li>
					             </c:when>
					             <c:otherwise>
			           <li id="${itemTemp.id}"><span>${itemTemp.name}</span></li>
					             </c:otherwise>
					           </c:choose>
			                </c:otherwise>
			             </c:choose>
			           </c:forEach>
		        </ul>
		      </li>
		      
		      <%
		      @SuppressWarnings("unchecked")
		      List<Long> cateIdList = (List<Long>)request.getAttribute("resourceIds");
		      @SuppressWarnings("unchecked")
		      Map<Long,List<Resource>> parentCateListMap = (Map<Long,List<Resource>>)request.getAttribute("map");
		      if(parentCateListMap!=null && parentCateListMap.keySet().size()>0){
		         int liIndex = 0;
		         for(Long pId:parentCateListMap.keySet()){
		            liIndex++;
		       %>
		                <li id="_o_l_<%=liIndex%>">
		                  <ul id="_o_l_u_<%=liIndex%>">
		       <%
		            List<Resource> cateList = parentCateListMap.get(pId);
		            for(Resource cate:cateList){
		                     if("0".equals(cate.getIsLeaf())){
		                        if(cateIdList.contains(cate.getId())){
		                    %>
		                    <li id="<%=cate.getId()%>" class="parent selected"><span><%=cate.getName()%></span></li>
		                    <%
		                        }else{
		                    %>
		                    <li id="<%=cate.getId()%>" class="parent"><span><%=cate.getName()%></span></li>
		                    <%
		                        }
		                     }else{
		                        if(cateIdList.contains(cate.getId())){
		                    %>
		                    <li id="<%=cate.getId()%>" class="selected"><span><%=cate.getName()%></span></li>
		                    <%
		                        }else{
		                    %>
		                    <li id="<%=cate.getId()%>"><span><%=cate.getName()%></span></li>
		                    <%
		                        }
		                     }
		          }
		      %>
		                  </ul>
		                </li>
		      <%
		         }
		      }
		      %>
		    </ol>
		  </div>
        </td>
      </tr>
      <tr>
        <td class="label">排序</td>
        <td>
          <input name="sortOrder" size="15" value="${resource.sortOrder}" readonly="readonly"/></td>
      </tr>
      </table>
      <div class="button-div">
        <input type="submit" value=" 确定 " />
        <input type="reset" value=" 重置 " />
      </div>
</div>
</body>
</html>